export const usePagination = ()=>{
	import {ref} from 'vue'
	const list = ref([]);
	const loading = ref(false);
	const noMoreData = ref(false);
	const pageNum = ref(1);
	const pageSize = ref(10);
	
const fetchList = async (refresh = false) => {
  loading.value = true;
  try {
    const res = await getListData(pageNum.value, pageSize.value); // 替换为实际的API调用
    if (refresh) {
      list.value = res.data.records;
    } else {
      list.value = [...list.value, ...res.data.records];
    }
    noMoreData.value = res.data.records.length < pageSize.value;
    pageNum.value++;
  } catch (error) {
    console.error('获取数据失败:', error);
  } finally {
    loading.value = false;
  }
};
const refreshList = async () => {
  pageNum.value = 1;
  noMoreData.value = false;
  await fetchList(true);
};

const loadMoreList = async () => {
  if (!noMoreData.value) {
    await fetchList(false);
  }
};
}